package org.com.blbl.sortHighQualityUpTop10;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.com.blbl.bean.BiliSortBean;

import java.io.IOException;

public class SortHighQualityUpTop10Mapper extends Mapper<LongWritable, Text, BiliSortBean, Text> {

    //创建输出对象
    private BiliSortBean outKey = new BiliSortBean();
    private Text outValue = new Text();

    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        //读取一行数据进行切割
        String[] fields = value.toString().split("\t");
        //获得up
        String up = fields[0];
        //每周最大期数
        long weeklyBigNum = Long.parseLong(fields[1]);
        //填充数据
        outKey.set(weeklyBigNum);
        outValue.set(up);
        //输出结果
        context.write(outKey, outValue);

    }
}
